package work10;

import java.util.Random;

public class Task05 {
    public static void main(String[] args) {
        int random = (int) (Math.random() * 100 + 1);
        System.out.println("使月Math的random方法生成1至100 之间的随机数:" + random);

        Random r = new Random();
        System.out.println("使用Random()类生成int型随机数:" + r.nextInt());
        System.out.println("使用Random()类生成1到100 的随材数:" + (r.nextInt(100) + 1));
        System.out.println("使用Random()构造方法生成5个随机数(执行2次值不同) ;");
        for (int i = 0; i < 5; i++) {
            System.out.println(r.nextInt(100));
        }
        Random r2 = new Random(5);
        System.out.println("使用Ran dom(long 构造方法生成5个随机数(执行2次值一样):");
        for (int i = 0; i < 5; i++) {
            System.out.println(r2.nextInt(100));
        }
    }
}
